package com.gome.han.bigdata.spark.core.rdd.operation.action

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author Hanpeng
 * @date 2021/1/14 21:05
 * @description:
 */
object CountByValueOperation {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Operator")
    val sc = new SparkContext(sparkConf)

    val rdd = sc.makeRDD(List(1,1,1,4),2)
    /*val rdd = sc.makeRDD(List(
      ("a", 1),("a", 2),("a", 3),("b",100),("a",10000),("a",1)
    ))*/

    // TODO - 行动算子

    val intToLong: collection.Map[Int, Long] = rdd.countByValue()
    println(intToLong)
    //val stringToLong: collection.Map[String, Long] = rdd.countByKey()
    //println(stringToLong)

    sc.stop()

  }
}
